package com.czh.controller;

import com.czh.domain.ResponseResult;
import com.czh.domain.dto.RoleDto;
import com.czh.domain.dto.ChangeRoleStatusDto;
import com.czh.domain.dto.QueryRoleDto;
import com.czh.domain.entity.Role;
import com.czh.domain.vo.RolePageVo;
import com.czh.domain.vo.RoleVo;
import com.czh.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 角色管理控制器
 */
@RestController
@RequestMapping("system/role")
public class RoleManageController {
    @Autowired
    private RoleService roleService;
    /**
     * 这是角色管理的角色列表
     */
    @GetMapping("/list")
    public ResponseResult<RolePageVo> getRoleLst(Integer pageNum, Integer pageSize, QueryRoleDto userDto) {
        return roleService.getRoleLst(pageNum,pageSize,userDto);
    }
    /**
     * 这是新增用户的角色列表
     */
    @GetMapping("/listAllRole")
    public ResponseResult<List<Role>> getAddRoleList(){
        return roleService.getAllRoleList();
    }
    @PutMapping("/changeStatus")
    public ResponseResult<Object> changeStatus(@RequestBody ChangeRoleStatusDto changeRoleStatusDto){
        return roleService.changeStatus(changeRoleStatusDto);
    }
    @PostMapping
    public ResponseResult<Object> addRole(@RequestBody RoleDto roleDto){
        return roleService.addRole(roleDto);
    }
    @DeleteMapping("/{id}")
    public ResponseResult<Object> deleteRole(@PathVariable Long id){
        return roleService.deleteRole(id);
    }
    @PutMapping
    public ResponseResult<Object> updateRole(@RequestBody RoleDto roleDto){
         return roleService.updateRole(roleDto);
    }
    @GetMapping("{id}")
    public ResponseResult<RoleVo> getRoleById(@PathVariable("id")Long id){
        return  roleService.getRoleById(id);
    }
}
